import java.util.Scanner;

public class test1 {
    public static class UserLogin{
        private String userName = "王嘉骏";
        private  String passWord= "20020404w";
        public void Login(String name ,String pass)throws passException,nameException{
            if(!name.equals(userName)){
                throw  new nameException("用户名错误");
            }else if(!pass.equals(passWord)){
                throw new passException("密码错误");
            }else {
                System.out.println("登录成功！");
            }
        }
    }

    public static void main(String[] args) {
        UserLogin userLogin = new UserLogin();
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = scanner.nextLine();
        System.out.println("请输入密码：");
        String pass = scanner.nextLine();
        try{
            userLogin.Login(name,pass);
        }catch (nameException e){
            System.out.println("用户名错误");
        }catch (passException e){
            System.out.println("密码错误");
        }
        System.out.println();
        userLogin.Login(name,pass);
    }
}
